package com.icity.mapper;

import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import com.icity.entity.ad.AdSummary;
import com.icity.entity.ad.Banner;

@Mapper
public interface AdMapper {
    //查询菜单数量
	@Select("<script>"
			+"select count(id) from tbl_banner where 1 = 1"
			+ "<if test='name != null'>"
			+ " and name like CONCAT('%','${name}','%' ) "
			+ "</if>"
			+ "<if test='position != null'>"
			+ " and position = #{position} "
			+ "</if>"
			+ "<if test='start_time != null'>"
			+ " and start_time like CONCAT('%','${start_time}','%') "
			+ "</if>"
			+ "<if test='end_time != null'>"
			+ " and end_time like CONCAT('%','${end_time}','%') "
			+ "</if>"
			+ " </script>")
    int getBannerCount(Map<Object,Object> map);

    //查询菜单
	@Select("<script>"
			+"select * from tbl_banner where 1 = 1 "
			+ "<if test='name != null'>"
			+ " and name like CONCAT('%','${name}','%') "
			+ "</if>"
			+ "<if test='position != null'>"
			+ " and position = #{posotion} "
			+ "</if>"
			+ "<if test='start_time != null'>"
			+ " and start_time like CONCAT('%','${start_time}','%') "
			+ "</if>"
			+ "<if test='end_time != null'>"
			+ " and end_time like CONCAT('%','${end_time}','%') "
			+ "</if>"
			+ " ORDER BY update_time desc "
			+ "limit #{page},#{limit}"
			+ " </script>")
    List<Banner> getBannerList(Map<Object,Object> map);

    @Select("select * from tbl_statistics_ad_summary where type = #{type} and date between #{startDate} and "
    		+ "#{endDate}  order by date")
	List<AdSummary> getAdSummary(Map<Object, Object> map);
}
